package prg;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public abstract class SWTApplication
{
    protected final Display display = new Display();
    protected final Shell shell = new Shell( display );


    public SWTApplication()
    {
        createControl( shell );
    }


    abstract protected void createControl( Composite parent );


    public void run()
    {
        shell.open();
        while ( !shell.isDisposed() )
            if ( !display.readAndDispatch() )
                display.sleep();
        display.dispose();

    }


    public Shell getShell()
    {
        return shell;
    }

}
